package com.coollang.smartbra.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.coollang.smartbra.R;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: Timmy
 * @Data: 2017/4/26
 * @Fuction: 红包页面的Recyleview
 */

public class RedEnvelopesAdapter extends RecyclerView.Adapter {

    private Context mContext;
    private List<String> mList = new ArrayList();

    public RedEnvelopesAdapter(Context context) {
        mContext = context;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_red_envelopes, parent, false);

        ViewHolder vh = new ViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;

        if (position == 0) {
            viewHolder.mLine.setVisibility(View.INVISIBLE);
        } else {
            viewHolder.mLine.setVisibility(View.VISIBLE);
        }

       // viewHolder.bindData(mList.get(position));
    }

    @Override
    public int getItemCount() {
        if (mList != null && mList.size() > 0) {
            return mList.size();
        }
        return 10;
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public View mLine;
        public TextView mAction;
        public TextView mMoney;
        public TextView mTime;

        public ViewHolder(View itemView) {
            super(itemView);
            //由于itemView是item的布局文件，我们需要的是里面的textView，因此利用itemView.findViewById获
            //取里面的textView实例，后面通过onBindViewHolder方法能直接填充数据到每一个textView了
            mLine = itemView.findViewById(R.id.view_line);
            mAction = (TextView) itemView.findViewById(R.id.item_red_action);
            mMoney = (TextView) itemView.findViewById(R.id.item_red_money);
            mTime = (TextView) itemView.findViewById(R.id.item_red_time);
        }

        public void bindData(String str) {

        }
    }
}
